import { ScreenEnum, SizeEnum } from "@/config";
import { useScreen } from "@/hooks";
import { useProjectStore } from "@/store/modules/projectStore";
import { defineComponent, onBeforeUnmount } from "vue";

export interface AppBootstrapProps {}

export default defineComponent<AppBootstrapProps>({
  name: "AppBootstrap",
  setup(props, { slots }) {
    let { createbreakPointEvent } = useScreen();

    let { setIsMobile } = useProjectStore();

    //判断是否为移动版
    let { removeFn } = createbreakPointEvent(
      (screen: SizeEnum, width: number) => {
        let mobileValidate = width <= ScreenEnum.LG;
        setIsMobile(mobileValidate)
      }
    );
    onBeforeUnmount(()=>{
      //在卸载前销毁监听
      removeFn()
    })
    return () => <>{slots.default?.()}</>;
  },
});
